<?php
/**
 * 管理员基础权限
 * User: cxm
 * Date: 2019/1/17
 * Time: 17:26
 */
namespace Seeds\Admin;
use App\Models\AdminPermission;
class AdminSeeder {
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public static function run(){
        // 用户管理 (1级)
        $admin_user = AdminPermission::create([
            'pid' => 0, 'sort' => 1, 'http_method' => ['GET'], 'name' => '管理员', 'fid' => null, 'icon' => 'el-icon-s-custom',
            'http_path' => 'javascript', 'menu_switch' => 2,'slug'=>'admin'
        ]);

        /** ------------------------------------------ 角色start --------------------------------------------------*/
        //角色列表  2级
        $permission_role = AdminPermission::create([
            'pid' => $admin_user->id, 'sort' => 10, 'http_method' => ['GET'], 'name' => '权限角色', 'fid' => null, 'icon' => 'layui-icon-read',
            'url'=>'role_list','http_path' => 'javascrip:;', 'menu_switch' => 2
        ]);

        //获取角色数据 3级
        AdminPermission::create([
            'pid' => $permission_role->id, 'sort' => 10, 'http_method' => ['POST'], 'name' => '角色列表', 'fid' => $permission_role->id, 'icon' => '',
            'http_path' => '/admin/role/get-lists', 'menu_switch' => 1
        ]);

        //角色详情
        AdminPermission::create([
            'pid' => $permission_role->id, 'sort' => 20, 'http_method' => ['GET'], 'name' => '详情', 'fid' => null, 'icon' => '',
            'http_path' => '/admin/role/detail', 'menu_switch' => 1
        ]);

        //新建角色操作  3级
        AdminPermission::create([
            'pid' => $permission_role->id, 'sort' => 20, 'http_method' => ['POST'], 'name' => '编辑操作', 'fid' => null, 'icon' => '',
            'http_path' => '/admin/role/store', 'menu_switch' => 1
        ]);

        //删除角色
        AdminPermission::create([
            'pid' => $permission_role->id, 'sort' => 20, 'http_method' => ['POST'], 'name' => '删除', 'fid' => null, 'icon' => '',
            'http_path' => '/admin/role/delete', 'menu_switch' => 1
        ]);
        /** ------------------------------------------ 角色 end --------------------------------------------------*/

        /** ------------------------------------------ 管理员 --------------------------------------------------*/
        // 用户管理 - 管理员 (2级)
        $user_operate = AdminPermission::create([
            'pid' => $admin_user->id, 'sort' => 20,'http_method'=>['GET'], 'name' => '管理员', 'fid' => NULL, 'icon' => '',
            'url'=>'admin_list','menu_switch' => 2, 'http_path' => 'javascrip:;'
        ]);

        // 用户管理 - 附属路由
        AdminPermission::create([
            'pid' => $user_operate->id, 'sort' => 1,'http_method'=>['POST'], 'name' => '用户管理-附属', 'fid' => $user_operate->id, 'icon' => '',
            'menu_switch' => 1, 'http_path' => '/admin/manage/get-lists'
        ]);

        // 用户管理 - 管理员 - 删除 (3级)
        AdminPermission::create([
            'pid' => $user_operate->id, 'sort' => 3,'http_method'=>['POST'], 'name' => '删除', 'fid' => NULL, 'icon' => '',
            'menu_switch' => 1, 'http_path' => '/admin/manage/delete'
        ]);

        AdminPermission::create([
            'pid' => $user_operate->id, 'sort' => 3,'http_method'=>['POST'], 'name' => '编辑', 'fid' => NULL, 'icon' => '',
            'menu_switch' => 1, 'http_path' => '/admin/manage/edit'
        ]);

        AdminPermission::create([
            'pid' => $user_operate->id, 'sort' => 3,'http_method'=>['POST'], 'name' => '添加、编辑处理', 'fid' => NULL, 'icon' => '',
            'menu_switch' => 1, 'http_path' => '/admin/manage/store'
        ]);

        // 修改角色
        AdminPermission::create([
             'pid' => $user_operate->id, 'sort' => 3,'http_method'=>['POST'], 'name' => '修改角色', 'fid' => NULL, 'icon' => '',
             'menu_switch' => 1, 'http_path' => '/admin/manage/editRole'
        ]);
        // 冻结/解冻
        AdminPermission::create([
            'pid' => $user_operate->id, 'sort' => 3,'http_method'=>['POST'], 'name' => '冻结/解冻', 'fid' => NULL, 'icon' => '',
            'menu_switch' => 1, 'http_path' => '/admin/manage/updateStatus'
        ]);
        // 重置密码
        AdminPermission::create([
            'pid' => $user_operate->id, 'sort' => 3,'http_method'=>['POST'], 'name' => '重置密码', 'fid' => NULL, 'icon' => '',
            'menu_switch' => 1, 'http_path' => '/admin/manage/set_pass'
        ]);
    }
}